package com.nandi.emergencyinspection.ui.activity.macro

import android.os.Bundle
import androidx.recyclerview.widget.GridLayoutManager
import com.nandi.emergencyinspection.R
import com.nandi.emergencyinspection.bean.MacroInfoListBean
import com.nandi.emergencyinspection.weight.imgselect.FullyGridLayoutManager
import com.nandi.emergencyinspection.ui.adapter.MacroInfoImgAdapter
import com.tbright.ktbaselibrary.base.BaseActivity
import kotlinx.android.synthetic.main.activity_macro_info.*
import kotlinx.android.synthetic.main.header_layout.*

class MacroInfoActivity : BaseActivity() {
    lateinit var serializableExtra: MacroInfoListBean.RecordsBean
    lateinit var mAdapter: MacroInfoImgAdapter
    override fun getLayoutId(): Int {
        return R.layout.activity_macro_info
    }

    override fun initView(savedInstanceState: Bundle?) {
        center_txt.text = "宏观观测详情"
        serializableExtra = intent.getSerializableExtra("bean") as MacroInfoListBean.RecordsBean
        left_icon.setOnClickListener { finish() }
        allNumber.text = serializableExtra.pikk
        disaster_name.text = serializableExtra.name
        disaster_location.text = serializableExtra.remark
        remark.text = serializableExtra.remark
        disaster_location.text = serializableExtra.location
        disaster_lon.text = serializableExtra.longitude
        disaster_lat.text = serializableExtra.latitude
        time.text = serializableExtra.createTime
        var results: String = if (1 == serializableExtra.warnLevel) {
            "红色告警"
        } else if (2 == serializableExtra.warnLevel) {
            "橙色告警"
        } else if (3 == serializableExtra.warnLevel) {
            "黄色告警"
        } else if (4 == serializableExtra.warnLevel) {
            "蓝色告警"
        } else {
            "正常"
        }
        result.text = results
        macro.text = serializableExtra.macroInfo
        val manager = FullyGridLayoutManager(
            this,
            4, GridLayoutManager.VERTICAL, false
        )
        photoData.layoutManager = manager
        mAdapter = MacroInfoImgAdapter(serializableExtra.voList!!.toMutableList())
        photoData.adapter = mAdapter


    }


}